package com.jingdianjichi.subject.infra.basic.utils;

import com.alibaba.druid.filter.config.ConfigTools;
import org.springframework.beans.factory.annotation.Value;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

public class DruidEncryptUtil
{
    @Value("${publicKey}")
    private static String publicKey;

    @Value("${privateKey}")
    private static String privateKey;

    /*static{
        try {
            String[] keyPair = ConfigTools.genKeyPair(512);
            privateKey = keyPair[0];
            System.out.println("privateKey = " + privateKey);
            publicKey = keyPair[1];
            System.out.println("publicKey = " + publicKey);

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (NoSuchProviderException e) {
            e.printStackTrace();
        }
    }*/


/*    public static String decrypt(String cipherText) throws Exception {
            String decrypt = ConfigTools.decrypt(privateKey, cipherText);
            System.out.println("decrypt = " + decrypt);
            return decrypt;
    }

    public static String encrypt(String cipherText) throws Exception {
        String encrypt = ConfigTools.encrypt(privateKey, cipherText);
        System.out.println("decrypt = " + encrypt);
        return encrypt;
    }*/

  /*  public static void main(String[] args) throws Exception {
        String encrypt = encrypt("123");
        System.out.println("encrypt = " + encrypt);
    }*/



}
